#include <scott/CommandDescriptor.h>

BOOST_AUTO_TEST_SUITE( CommandDescriptor_Test_Suite )

BOOST_AUTO_TEST_CASE( CommandDescriptor_Create_Test )
{
	// Data
	CommandDescriptorSp cd = CommandDescriptor::Create("plugin", "SimpleCommand", "SimpleCommand description");

	cd->AddInputParameter("B", "A SByte", STypeByte);
	cd->AddInputParameter("C", "A SChar", STypeChar);
	cd->AddInputParameter("Num", "A SNumber", STypeNumber);
	cd->AddInputParameter("Str", "A String", STypeString);

	cd->AddOutputParameter("B", "A SByte", STypeByte);
	cd->AddOutputParameter("C", "A SChar", STypeChar);
	cd->AddOutputParameter("Num", "A SNumber", STypeNumber);
	cd->AddOutputParameter("Str", "A String", STypeString);

	// Test input parameters
	BOOST_CHECK( cd->GetName() == "SimpleCommand" );
	BOOST_CHECK( cd->GetPluginName() == "plugin" );
	BOOST_CHECK( cd->GetFullyQualifiedName() == "plugin.SimpleCommand" );
	BOOST_CHECK( cd->GetDescription() == "SimpleCommand description" );
	BOOST_CHECK( cd->GetNumberOfInputParameters() == 4 );

	BOOST_CHECK( cd->GetInputParameter(0)->GetName() == "B" );
	BOOST_CHECK( cd->GetInputParameter(1)->GetName() == "C" );
	BOOST_CHECK( cd->GetInputParameter(2)->GetName() == "Num" );
	BOOST_CHECK( cd->GetInputParameter(3)->GetName() == "Str" );
	BOOST_CHECK_THROW( cd->GetInputParameter(4), SArgumentException );

	BOOST_CHECK( cd->GetInputParameter("B")->GetName() == "B" );
	BOOST_CHECK( cd->GetInputParameter("C")->GetName() == "C" );
	BOOST_CHECK( cd->GetInputParameter("Num")->GetName() == "Num" );
	BOOST_CHECK( cd->GetInputParameter("Str")->GetName() == "Str" );
	BOOST_CHECK_THROW( cd->GetInputParameter("N"), SArgumentException );

	BOOST_CHECK( cd->IsInputParameterDefined("Num") == true );
	BOOST_CHECK( cd->IsInputParameterDefined("N") == false );

	// Test output parameters
	BOOST_CHECK( cd->GetOutputParameter(0)->GetName() == "B" );
	BOOST_CHECK( cd->GetOutputParameter(1)->GetName() == "C" );
	BOOST_CHECK( cd->GetOutputParameter(2)->GetName() == "Num" );
	BOOST_CHECK( cd->GetOutputParameter(3)->GetName() == "Str" );
	BOOST_CHECK_THROW( cd->GetOutputParameter(4), SArgumentException );

	BOOST_CHECK( cd->GetOutputParameter("B")->GetName() == "B" );
	BOOST_CHECK( cd->GetOutputParameter("C")->GetName() == "C" );
	BOOST_CHECK( cd->GetOutputParameter("Num")->GetName() == "Num" );
	BOOST_CHECK( cd->GetOutputParameter("Str")->GetName() == "Str" );
	BOOST_CHECK_THROW( cd->GetOutputParameter("N"), SArgumentException );

	BOOST_CHECK( cd->IsOutputParameterDefined("Num") == true );
	BOOST_CHECK( cd->IsOutputParameterDefined("N") == false );
}

BOOST_AUTO_TEST_SUITE_END()
